import React ,{useEffect,useState}from 'react';
import { connect } from 'react-redux';
import moment from 'moment';
import { Modal,
Form, Input, Button,DatePicker,Select,Divider,LocaleProvider,Collapse} from 'antd';
import {Link} from 'react-router-dom'
import { RollbackOutlined } from '@ant-design/icons';
import zh_CN from 'antd/lib/locale-provider/zh_CN';
import 'moment/locale/zh-cn';
moment.locale('zh-cn');
import {PlusOutlined} from '@ant-design/icons'
import styles from './styles.less'
import { eq } from 'lodash';




function setEqMessage(props) { 
    const { keepDatas,putDataFsm,FSMneedDatas,backImgList,user,newEquipPosition } = props;
    const { equipInfo, positionInfo, status } = props
    console.log(newEquipPosition);
    let equip = {},
        pipeData=[],
        implData=[],
        initData=[], 
        k = 0,
        p= 0,
        o = 0,
        equipM = null,
        equipN = null,
        equipYxLs  = null,
        positionMessage = null,
        positionInit = null
    const { Option } = Select;
    const [num,setNum] = useState([1])
    const [item,setItem] = useState(0);
    const [AjaxDatas,setAjaxDatas] = useState(null);
    const [equipType,setEquipType] = useState('FSM')
    const [X,setX] = useState({
        x:0,
        y:0,
    });
    const [isModalVisible, setIsModalVisible] = useState(false);
    const [displayStyle,setDisplayStyle] = useState(false);
    if( status != 'add' ) {
      console.log(equipInfo);
      if(equipInfo.linkedHashMap) {
        equip = equipInfo.linkedHashMap.fsmVo2
        positionMessage = equipInfo.positionInfoList[0]
        positionInit = equipInfo.positionInfoList[0].positionInfo.description
        // console.log('******')
        // console.log(equip)
        equipYxLs = (Number(equip.n) - 1).toString()
        // console.log(equip.m)
        // console.log(equipInfo);
        // console.log(equip.n)
        // console.log('******')
        equipM = equip.m
        equipN = equip.n
        equip.pipeThickness.map((item,index)=>{
            item.map((item,index)=>{
                if(index === 2){
                    pipeData.push(item)//存入壁厚矩阵的具体数值
                }
            })
        })
        equip.implFactor.map((item,index)=>{
            item.map((item,index)=>{
                if(index === 2){
                    implData.push(item)//存入牵扯矩阵的具体数值
                }
            })
        })
        equip.initVoltage.map((item,index)=>{
            item.map((item,index)=>{
                if(index === 2){
                    initData.push(item)//存入电极矩阵的具体数值
                }
            })
        })
        // console.log(initData)
        // setDisplayStyle(true)
        // let values = {
        //     x:equip.m,
        //     y:equip.n
        // }
        // setX(values)
        // console.log(X)
      }
    }
    const showModal = () => {
      setIsModalVisible(true);
    };
    let List = []
    const MakeDJJuzhen = ()=>{
        let M,N;
        List.push(<div style={{marginTop:50+'px'}}>初始电极矩阵：</div>)
        List.push(<br/>)
        if( status != 'add' ) {
            M = ++equipM;
            N = --equipN;
        }else{
            M = X.x;
            N = X.y
        }
        // console.log(M,N, equip, X, status)
        for(let i = 1;i<=M;i++){
            for(let j = 1;j<=N;j++){
                if(i === 1){
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`行/列`}/>)
                    }
                    List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${j}`}/>)
                }else{
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${i-1}`}/>)
                    }
                    List.push(<Form.Item  name={`^${i-1},${j}`} className={styles.juzhenItem} key={`^${i},${j}`}><Input className={styles.input_juzhen }  defaultValue={`${initData.length !== 0 ?initData[o]:''}`} /></Form.Item>)
                    o++;
                }
            }
            List.push(<br/>)
        }
        return List
    }
    const MakeQCJuzhen = ()=>{
        let M,N;
        let List = [];
        List.push(<div style={{marginTop:50+'px'}}>牵扯因子矩阵：</div>)
        List.push(<br/>)
        if( status != 'add' ) {
            M = equipM;
            N = equipN;
        }else{
            M = X.x;
            N = X.y
        }
        for(let i = 1;i<=M;i++){
            for(let j = 1;j<=N;j++){
                if(i === 1){
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`行/列`}/>)
                    }
                    List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${j}`}/>)
                }else{
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${i-1}`}/>)
                    }
                    List.push(<Form.Item  name={`*${i-1},${j}`} className={styles.juzhenItem} key={`*${i},${j}`}><Input className={styles.input_juzhen }  defaultValue={`${implData.length !== 0?implData[p]:''}`} /></Form.Item>)
                    p++;
                }
            }
            List.push(<br/>)
        }
        return List
    }
    const MakeBHJuzhen = ()=>{
        let M,N;
        let List = [];
        List.push(<div style={{marginTop:50+'px'}}>初始壁厚矩阵：</div>)
        List.push(<br/>)
        if( status != 'add' ) {
            M = equipM;
            N = equipN;
        }else{
            M = X.x;
            N = X.y
        }
        for(let i = 1;i<=M;i++){
            for(let j = 1;j<=N;j++){
                if(i === 1){
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`行/列`}/>)
                    }
                    List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${j}`}/>)
                }else{
                    if(j === 1){
                        List.push(<Input disabled="true" className={styles.input_juzhen}  defaultValue={`${i-1}`}/>)
                    }
                    List.push(<Form.Item rules={[{ required: true, message: '矩阵必须填完！' }]} name={`${i-1},${j}`} className={styles.juzhenItem} key={`${i},${j}`}><Input className={styles.input_juzhen }  defaultValue={`${pipeData.length !== 0?pipeData[k]:''}`} /></Form.Item>)
                    k++;
                }
            } 
            List.push(<br/>)
        }
        return List
    }
    const onbutton = (values) => {
        // console.log('Success:', values.x);
        let value = {
            x:++values.x,
            y:values.y
        }
        setX(value)
        setDisplayStyle(true)
      };
    
      const onFinishFailed2 = (errorInfo) => {
        console.log('Failed:', errorInfo);
      };
    const handleOk = () => {
      setIsModalVisible(false);
      console.log(AjaxDatas)
      putDataFsm(AjaxDatas).then(res=>{
          console.log(res)
      })
    };
  
    const handleCancel = () => {
        setIsModalVisible(false);
    };
    const contorCsnsors = (a) =>{
        let csnsors = '',cgList = [],wzList = []
        for(let key in a){
            if(key.match(/^wz\d+/g)){
                wzList.push(key.match(/^wz\d+/g))
            }
            if(key.match(/^cg\d+/g)){
                cgList.push(key.match(/^cg\d+/g))
            }
        
        }
        wzList.map((item,index)=>{
            if(index == 0){
             csnsors =  a[item]+','+a[cgList[index]]
            }else{ 
                csnsors += '&'+a[item]+','+a[cgList[index]]
            }
        })
        return csnsors
    }
    const checkBhJz = (needValues)=>{
        let pipeThickness = []
        let k = 1,lm = 1;
        for(let key in needValues){
            if(key.match(/^\d+,\d+$/g) !== null){
                let keyCode = key.match(/^\d+,\d+$/g)[0].match(/^[1-9]/g)!==null?key.match(/^\d+,\d+$/g)[0].match(/^[1-9]/g)[0]:''
                // console.log(keyCode)
                if(keyCode !== '1'){
                    if(k !== keyCode){
                        pipeThickness.push(`/${needValues[key]}`)
                        k = keyCode
                        // console.log(k)
                    }else if(k == keyCode){
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }else{
                    if(lm == k){
                        pipeThickness.push(needValues[key])
                        lm = lm +1
                    }else{
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }
                // needValues[key]
            }
            // console.log(pipeThickness)
            // console.log(key.match(/^\d+,\d+$/g))
        }
       return pipeThickness.join('')
      }
      const checkQcJz = (needValues)=>{
        let pipeThickness = [],res;
        let k = 1,lm = 1;
        for(let key in needValues){
            if(key.match(/^\*\d+,\d+$/g) !== null){
                // console.log(key.match(/^\*\d+,\d+$/g)[0])
                let keyCode = key.match(/^\*\d+,\d+$/g)[0].match(/^\*[1-9]/g)!==null?key.match(/^\*\d+,\d+$/g)[0].match(/^\*[1-9]/g)[0]:''
                // console.log(keyCode)
                if(keyCode !== '1'){
                    if(k !== keyCode){
                        pipeThickness.push(`/${needValues[key]}`)
                        k = keyCode
                        // console.log(k)
                    }else if(k == keyCode){
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }else{
                    if(lm == k){
                        pipeThickness.push(needValues[key])
                        lm = lm +1
                    }else{
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }
                // needValues[key]
            }
            // console.log(pipeThickness)
            // console.log(key.match(/^\d+,\d+$/g))
        }
        res = pipeThickness.join('').split('')
        res.shift()
       return res.join('')
      }
      const checkDjJz = (needValues)=>{
        let pipeThickness = [],res;
        let k = 1,lm = 1;
        for(let key in needValues){
            if(key.match(/^\^\d+,\d+$/g) !== null){
                // console.log(key.match(/^\^\d+,\d+$/g)[0])
                let keyCode = key.match(/^\^\d+,\d+$/g)[0].match(/^\^[1-9]/g)!==null?key.match(/^\^\d+,\d+$/g)[0].match(/^\^[1-9]/g)[0]:''
                // console.log(keyCode)
                if(keyCode !== '1'){
                    if(k !== keyCode){
                        pipeThickness.push(`/${needValues[key]}`)
                        k = keyCode
                        // console.log(k)
                    }else if(k == keyCode){
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }else{
                    if(lm == k){
                        pipeThickness.push(needValues[key])
                        lm = lm +1
                    }else{
                        pipeThickness.push(`,${needValues[key]}`)
                    }
                }
                // needValues[key]
            }
            // console.log(pipeThickness)
            // console.log(key.match(/^\d+,\d+$/g))
        }
        res = pipeThickness.join('').split('')
        res.shift()
        console.log(res.join(''))
       return res.join('')
      }
    const onFinish = (values) => {
        // console.log('Success:', values);
        // console.log(values.csnsors);
        if (!values.csnsors) {
          values.csnsors = ',管道温度传感器'
        }
        // console.log(installTime,changeTime)
        // const needValues = values
        const needValues = values;
        console.log(values.installTime)
        needValues.csnsors = contorCsnsors(needValues)
        needValues.changeTime = moment(values.changeTime).format('YYYY-MM-DD')
        needValues.installTime = moment(values.installTime).format('YYYY-MM-DD')
        console.log(values.installTime)
        let Ln = parseInt(values.n)+1
        needValues.n = Ln.toString()
        // console.log(needValues)
        // needValues.map((item,index)=>{
        //     console.log(item.match(/^\d+,\d+$/g))
        // })
        // let pipeThickness = []
        // let k = 1,lm = 1;
        // for(let key in needValues){
        //     if(key.match(/^\d+,\d+$/g) !== null){
        //         let keyCode = key.match(/^\d+,\d+$/g)[0].match(/^[1-9]/g)!==null?key.match(/^\d+,\d+$/g)[0].match(/^[1-9]/g)[0]:''
        //         console.log(keyCode)
        //         if(keyCode !== '1'){
        //             if(k !== keyCode){
        //                 pipeThickness.push(`/${needValues[key]}`)
        //                 k = keyCode
        //                 console.log(k)
        //             }else if(k == keyCode){
        //                 pipeThickness.push(`,${needValues[key]}`)
        //             }
        //         }else{
        //             if(lm == k){
        //                 pipeThickness.push(needValues[key])
        //                 lm = lm +1
        //             }else{
        //                 pipeThickness.push(`,${needValues[key]}`)
        //             }
        //         }
        //         // needValues[key]
        //     }
        //     // console.log(pipeThickness)
        //     // console.log(key.match(/^\d+,\d+$/g))
        // }
        // console.log(pipeThickness.join(''))
        console.log('dasdasdadsa')
        needValues.pipeThickness = checkBhJz(needValues)
        console.log('xiaosila')
        // needValues.pipeThickness = pipeThickness.join('')
        // needValues.initVoltage = '//'
        if(checkDjJz(needValues).match(/^undefined/g) || checkDjJz(needValues).match(/^,/g)){
            needValues.initVoltage = '//'
        }else{
            needValues.initVoltage =  checkDjJz(needValues)
        }
        if(checkQcJz(needValues).match(/^undefined/g)|| checkQcJz(needValues).match(/^,/g)){
            console.log('dasdasd5465465')
            needValues.implFactor = '//'
        }else{
            console.log(checkQcJz(needValues).match(/^undefined/g))//填了删除是null
            needValues.implFactor =  checkQcJz(needValues)
        }
        // needValues.initVoltage = checkDjJz(needValues).match(/^undefined/g)[0] == 'undefined'? '//':checkDjJz(needValues)

        // // console.log(checkDjJz(needValues).match(/^\//))
        // needValues.implFactor = checkQcJz(needValues).match(/^undefined/g)[0] == 'undefined'? '//':checkQcJz(needValues)
        needValues.type = equipType
        console.log(needValues)
        setAjaxDatas(needValues)
      };
      const selectBefore = (
        <Select style={{width:400}} defaultValue="管道温度传感器" className="select-before">
          <Option value="管道温度传感器">管道温度传感器</Option>
          <Option value="参考板温度传感器">参考板温度传感器</Option>
        </Select>
      );
      const keepSen = (values) =>{

      }
    
      const formItemLayout = {
        labelCol: { span: 4 },
        wrapperCol: { span: 8 },
      };
      const deleteSen = (e)=>{
          const nowNum = num;
        num.map((item,index)=>{
            console.log(e)
            if(e === index){
                num.splice(index,1)
                setNum([...num])
            }
            console.log(num)
        })
        // nowNum.filter((_,index)=>index != e)
        // console.log(nowNum)
      }
      const onFinishFailed = (errorInfo) => {
        console.log('Failed:', errorInfo);
      };
      const handleChange = (value) => {
        console.log(`selected ${value}`);
      }
      const handleOnChange = (value) => {
          console.log('dasdasdasdasda')
          setEquipType(value)
      }
      const handleAdd = () =>{
        setNum([...num,item])
      }
      useEffect(()=>{
        // props.getOneEquip
        // getOnePosition()
        // console.log(backImgList)
        // console.log(position)
        console.log(props)
      },100)
    console.log(status);
    return (<React.Fragment>
                <Link to='/equipment/hotMap'><Button className={styles.linkStyle}><RollbackOutlined />返回设备列表</Button></Link> 
                <Divider>设备信息</Divider>
                <div className={styles.backColor}>
                {/* <Divider>FSM设备信息修改</Divider> */}
                <Form  
                        autoscroll='false'
                        name="basic"
                        labelCol={{
                            span: 8,
                        }}
                        wrapperCol={{
                            span: 16,
                        }}
                        initialValues={{
                            remember: true,
                        }}
                        onFinish={onFinish}
                        onFinishFailed={onFinishFailed}
                        autoComplete="off"
                        >
                        <div className={styles.content}>
                            {/* <Form.Item
                            {...formItemLayout}
                                key={1}
                                label="热点图ID"
                                name="imageId"
                                initialValue="pzzcpghe"
                                className={styles.boxStyle3}
                            >
                                <Input disabled/>
                            </Form.Item> */}
                            <Form.Item
                            {...formItemLayout}
                                label="太阳能电池板"
                                name="solarPanelJgbMj"
                                initialValue={status !='add' ? positionInfo.solarPanelJgbMj : ''}
                                className={styles.boxStyle3}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                            key={2}
                                label="CPU序列号"
                                name="fsmEquipmentId"
                                rules={[{ required: true, message: 'CPU序列号必填！' }]}
                                initialValue={status != 'add' ? equip.fsmEquipmentId : ''}
                                rules={[{ required: true, message: 'CPU序列号必填！' }]}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                            key={3}
                                label="单片机型号"
                                name="singleModelNum"
                                initialValue={status!='add' ? equip.singleModelNum : ''}
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            key={4}
                            {...formItemLayout}
                                label="单片机厂家"
                                name="singleModelFactory"
                                initialValue={status!='add' ? equip.singleModelFactory: ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                            defaultValue="create"
                            key={5}
                                label="设备ID"
                                name="equipId"
                                initialValue={status != 'add' ? equip.equipId : 'create'}
                                className={styles.boxStyle}
                            >
                                <Input disabled="true"/>
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="单位ID"
                                name="unitId"
                                initialValue={user.unitId}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="电极间距 行距"
                                name="poleX"
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="电极间距 列距"
                                name="poleY"
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="蓄电池功率"
                                name="batteryGl"
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="蓄电池电流"
                                name="batteryDl"
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="蓄电池电压"
                                name="batteryDy"
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="DTU厂家"
                                name="dtuCj"
                                initialValue={status != 'add' ? equip.dtuCj : ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="DTU型号"
                                name="dtuXh"
                                initialValue={status != 'add' ? equip.dtuXh : ''}
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="DTU物联卡号"
                                name="dtuKh"
                                initialValue={status != 'add' ? equip.dtuKh : ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="电池板额定功率"
                                name="solarPanelGl"
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="电池板额定电流"
                                name="solarPanelDl"
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="封装形式"
                                name="packageForm"
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="主控板版本"
                                name="masterVersion"
                                initialValue={status!='add' ? equip.masterVersion: ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="安装位置(设备名称)"
                                name="installPosition"
                                initialValue={status!='add' ? positionInit: ''}
                                rules={[{ required: true, message: '安装位置必填！' }]}
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="测量板版本"
                                name="measureVersion"
                                initialValue={status!='add' ? equip.measureVersion: ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="电极矩阵维度 行数"
                                name="m"
                                initialValue={status != 'add' ? equip.m : ''}
                                className={styles.boxStyle}
                                rules={[{ required: true, message: '行数必填！' }]}
                            >
                                <Input placeholder="请保持与下方生成矩阵 行数相同！" />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="电极矩阵维度 列数"
                                name="n"
                                initialValue={status != 'add' ? equipYxLs : ''}
                                rules={[{ required: true, message: '列数必填！' }]}
                                className={styles.boxStyle1}
                            >
                                <Input placeholder="请保持与下方生成矩阵 列数相同！" />
                            </Form.Item>
                            <Form.Item 
                            {...formItemLayout}
                            className={styles.boxStyle}
                            label="安装时间"
                            // initialValue={status != 'add' ? equip.installTime : ''}
                            name="installTime">
                                <LocaleProvider locale={zh_CN}>
                                    <DatePicker className={styles.boxStyless}/>
                                </LocaleProvider>
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="是否换版"
                                name="isChangePlate"
                                className={styles.boxStyle1}
                                initialValue={status!='add' ? equip.isChangePlate : ''}
                            >
                                <Select defaultValue="0"  style={{ width: 275 }} onChange={handleChange}>
                                    <Option value="1">是</Option>
                                    <Option value="0">否</Option>
                                </Select>
                            </Form.Item>
                            <Form.Item 
                            {...formItemLayout}
                            className={styles.boxStyle}
                            label="换板时间"
                            name="changeTime">
                                <LocaleProvider locale={zh_CN}>
                                    <DatePicker className={styles.boxStyless}/>
                                </LocaleProvider>
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="损失预值"
                                name="preLoss"
                                initialValue={status != 'add' ? equip.preLoss : ''}
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item><Form.Item
                            {...formItemLayout}
                                label="剩余预值"
                                name="preRest"
                                initialValue={status != 'add' ? equip.preRest : ''}
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="参考坐标"
                                name="reference"
                                initialValue="934,700.5"
                                className={styles.boxStyle1}
                            >
                                <Input disabled/>
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="ip地址"
                                name="ip"
                                rules={[{ required: true, message: 'IP地址必填！' }]}
                                initialValue={status != 'add' ? equip.ip : ''}
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="经度坐标"
                                initialValue={status !='add' ? positionInfo.x : newEquipPosition.x}
                                name="x"
                                className={styles.boxStyle1}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="纬度坐标"
                                name="y"
                                initialValue={status !='add' ? positionInfo.y : newEquipPosition.y }
                                className={styles.boxStyle}
                            >
                                <Input />
                            </Form.Item>
                            <Form.Item
                            {...formItemLayout}
                                label="设备类型"
                                name="type"
                                className={styles.boxStyle1}
                            >
                                <Select  defaultValue="FSM" disabled style={{ width: 275 }} onChange={handleOnChange}>
                                    <Option value='FSM'>FSM</Option>
                                    <Option value='PZT'>PZT</Option>
                                    <Option value='EMAT'>EMAT</Option>
                                </Select>
                            </Form.Item>
                            </div>
                        {/* </div> */}
                        <Button className={styles.sensor_button}  type="primary"  onClick={handleAdd}>
                          <PlusOutlined /> 添加传感器
                        </Button>
                        {num.map((item,index)=>{
                        return (<div className={styles.sensor} key = {index}>
                            <Form.Item 
                            {...formItemLayout}
                            // className={styles.enStyle}
                            name={`wz${index}`}
                            >
                        <Input style={{width:400}} addonBefore="传感器 位置及类型"  />
                        {/* <Button type="primary" onClick={keepSen}>
                            保存传感器信息
                        </Button> */}
                        </Form.Item>
                        <Form.Item 
                            {...formItemLayout}
                            name={`cg${index}`}
                            >
                        {selectBefore}
                        </Form.Item>
                        <Button type="danger" onClick={()=>{deleteSen(index)}}>
                        删除
                        </Button></div>)
                    })}
                        <div style={displayStyle === true ||status !== 'add'? {display:'block'}:{display:'none'}}>
                            <MakeDJJuzhen />
                        </div>
                        <div style={displayStyle === true || status !== 'add' ? {display:'block'}:{display:'none'}}>
                            <MakeQCJuzhen />
                        </div>
                        <div style={displayStyle === true || status !== 'add' ? {display:'block'}:{display:'none'}}>
                            <MakeBHJuzhen />
                        </div>
                        <Form.Item
                            wrapperCol={{
                            offset: 8,
                            span: 16,
                            }}
                        >
                            <Button className={styles.submit_button} onClick={showModal} type="primary" htmlType="submit">
                                确定提交
                            </Button>
                        </Form.Item>
                    </Form>
                    <Form
                        name="baSsic"
                        labelCol={{ span: 8 }}
                        wrapperCol={{ span: 16 }}
                        initialValues={{ remember: true }}
                        onFinish={onbutton}
                        onFinishFailed={onFinishFailed2}
                        autoComplete="off"
                        >
                        <div className={styles.input_Style}>
                        <Form.Item
                            label="行数"
                            name="x"
                            initialValue={status != 'add' ? equip.m : ''}
                        >
                            <Input style={{width:70}} />
                        </Form.Item>

                        <Form.Item
                            label="列数"
                            name="y"
                            initialValue={status != 'add' ? equipYxLs : ''}
                        >
                            <Input style={{width:70}}/>
                        </Form.Item>
                        

                        <Form.Item wrapperCol={{ offset: 8, span: 16 }}>
                            <Button disabled={status !== 'add'? true : false} type="primary" htmlType="submit">
                            生成矩阵
                            </Button>
                        </Form.Item>
                        </div>
                        </Form>
                    </div>  
                    <Modal title="填写信息确认" visible={isModalVisible} onOk={handleOk} onCancel={handleCancel}>
                        确定提交以上信息？

                    </Modal>
    </React.Fragment>)
}
const mapStateToProps = (state) =>{
  return {
    FSMneedDatas:state.setFSMMessagePage.FSMneedDatas,
    // backImgList: state.equipmentPage.backImgList,
    status: state.setFSMMessagePage.status,
    equipInfo: state.setFSMMessagePage.equipInfo,
    positionInfo: state.setFSMMessagePage.positionInfo,
    backImgList:state.equipmentPage.backImgList,
    user: state.user,
    newEquipPosition: state.equipmentPage.newEquipPosition
  }
}
const mapDispatchToProps = (dispatch) =>(
    {
        keepDatas:dispatch.setFSMMessagePage.keepDatas,
        putDataFsm:dispatch.setFSMMessagePage.putDataFsm,
        getOneEquip:dispatch.setFSMMessagePage.getOneEquip
    }
)
export default connect(
    mapStateToProps,mapDispatchToProps
)(setEqMessage)